<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>Title</title>
    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css"
          integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
    <style type="text/css">


        .row.search {
            margin-top: 60px;
        }

        .row.list {
            margin: 50px 0
        }
        .col-md-2{
            margin: 20px 0
        }

    </style>
</head>
<body>
<div class="container">
    <div class="row search">
        <div class="col-md-4 col-md-offset-3">
            <div class="input-group">
                <span class="input-group-addon" id="basic-addon1">查询年份： {{subyear}}</span>
                <input type="text" class="form-control" placeholder="请输入年份最后一位" aria-describedby="basic-addon1"
                       maxlength="1" v-model="lastlengthyear" @input="handleYear">
            </div>
        </div>
        <div class="col-md-4">
            <div class="input-group">
                <button class="btn btn-info btn-block" @click="search"><i class="glyphicon glyphicon-search"></i>
                </button>
            </div>
        </div>
    </div>
    <div class="row list">
        <template v-for="(month,index) in months">
            <div class="col-md-2">
                <div class="panel" :class="classname">
                    <div class="panel-heading"><h4 class="text-center">{{month}}月</h4></div>
                    <div class="panel-body"><p class="text-center bg-info">日报数量：<span class="text-danger">18</span></p>
                    </div>
                    <div class="panel-footer">
                        <button class="btn btn-info btn-block">详情</button>
                    </div>
                </div>
            </div>
        </template>
    </div>
</div>
<script src="../js/vue.min.js"></script>
<script type="text/javascript">
    new Vue({
        el: '.container',
        data: {
            currentyear: '',
            lastlengthyear: '',
            months: ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'],
            classname: 'panel-default'
        },
        computed: {
            subyear: function () {
                return new Date().getFullYear().toString().substring(0, new Date().getFullYear().toString().length - 1)
            }
        },
        methods: {
            handleYear: function () {
                this.lastlengthyear = this.lastlengthyear.replace(/\D/g, '');

            },
            search: function () {
                this.currentyear = this.subyear + this.lastlengthyear;
                if (this.currentyear.length !== 4) {
                    alert('写日报，不是找bug，输入时间可好！')
                } else {
                    window.location.href = "";
                }
            }
        }
    })
</script>
</body>
</html>
